//
//  ManagementCarViewController.m
//  Runone
//
//  Created by runone01 on 16/10/25.
//  Copyright © 2016年 runone. All rights reserved.
//

#import "ManagementCarViewController.h"
#import <MAMapKit/MAMapKit.h>
#import <AMapFoundationKit/AMapFoundationKit.h>
#import "Define.h"
#import "RequestHelper.h"
#import "MJExtension.h"
#import "CarManagerModel.h"
#import "AppDelegate.h"
#import "PromptUtil.h"
#import "CarManagerView.h"
#import "VehicleInquiryController.h"
#import "CustomAnnotationView.h"
#import "CustomCallOutView.h"
#import "ROPointAnnotation.h"
#import "InVehicleDetailViewController.h"
#import "EnterMessageController.h"
//#import "UIColor+ZXLazy.h"
#import "SVProgressHUD.h"
#import "RightCodeTool.h"
#import "SVProgressHUD.h"
#import "OneConst.h"
#import "SRWebSocket.h"
#import "Define.h"
#import "AppLocalManager.h"
#import "GaoJinViewController.h"
#import "DataCodeModel.h"
#import "RequestOutginseng.h"
#import "AppDelegate.h"

@interface ManagementCarViewController ()<MAMapViewDelegate,SRWebSocketDelegate,UITabBarControllerDelegate>

@property (nonatomic, strong) MAMapView *mapView;
@property (weak, nonatomic) IBOutlet UIButton *menu;
@property(nonatomic, strong)SRWebSocket *socket;
@property (weak, nonatomic) IBOutlet UIView *HengView;
// ********************** --- 需要控制权限的 --- **********************
@property (weak, nonatomic) IBOutlet UIButton *xingzhengBtn;
@property (weak, nonatomic) IBOutlet UIButton *luzhengBtn;
@property (weak, nonatomic) IBOutlet UIButton *jiuyuanBtn;
@property (weak, nonatomic) IBOutlet UIButton *yanghuBtn;
@property (weak, nonatomic) IBOutlet UIButton *luruBtn;

@property (weak, nonatomic) IBOutlet UIView *shuView;
@property (weak, nonatomic) IBOutlet UIView *scaleView;
@property (weak, nonatomic) IBOutlet UIButton *lukuangBtn;

@property(nonatomic,strong) CarManagerModel *model;
@property(nonatomic,strong) NSMutableArray *mutableArray;
@property(nonatomic,strong) NSMutableArray *pointArray;
@property(nonatomic,strong) NSMutableArray *luzhengArray;
@property(nonatomic,strong) NSMutableArray *jiuyuanArray;
@property(nonatomic,strong) NSMutableArray *yanghuArray;
@property(nonatomic,strong) NSMutableArray *xiaofangArray;
@property(nonatomic,strong) NSMutableArray *xingzhengArray;
@property(nonatomic,strong) PromptUtil *prot;
@property(nonatomic,strong) CarManagerView *carView;
@property(nonatomic,strong) EnterMessageController *enterModer;

@property (nonatomic, strong) NSMutableArray *dataArray;//数据

@property(nonatomic)float la,lo;

@property (nonatomic, assign) BOOL viewSelected;
@property(nonatomic)int selectCount;
@property(nonatomic,strong)NSMutableArray *CarIdArray;
@end

@implementation ManagementCarViewController

#pragma    --------车辆管理主界面



- (void)viewDidLoad {
    [super viewDidLoad];
    self.tabBarController.tabBar.hidden = NO;
    [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:(68.0 / 255) green:(169.0 / 255) blue:(213.0 / 255) alpha:1.000]];
    self.navigationController.navigationBar.tintColor=[UIColor whiteColor];
    UILabel *label=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 150, 30)];
    label.text=@"车辆管理";
    label.textAlignment=NSTextAlignmentCenter;
    label.textColor=[UIColor whiteColor];
    self.navigationItem.titleView=label;
    [self loadMapView];
    [self defaultAnnimation];
    self.tabBarController.delegate=self;
    //    [self request];
    _mapView.delegate=self;
    [_lukuangBtn setBackgroundImage:[UIImage imageNamed:@"traffic_light"] forState:UIControlStateNormal];
    _dataArray = [[NSMutableArray alloc] init];
    
    _pointArray=[[NSMutableArray alloc] init];
    
    _xingzhengArray=[[NSMutableArray alloc] init];
    _luzhengArray=[[NSMutableArray alloc] init];
    _jiuyuanArray=[[NSMutableArray alloc] init];
    _yanghuArray=[[NSMutableArray alloc] init];
    _CarIdArray=[[NSMutableArray alloc] init];
    _xiaofangArray = [[NSMutableArray alloc] init];
    _enterModer=[[EnterMessageController alloc] init];
    
    _prot=[[PromptUtil alloc] init];
    [self Request];
//    NSLog(@"%@",_CarIdArray);
    _la = 0.8;
    _lo = 0.9;
    // 监听通知
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tabBarButtonRepeatClick) name:ROTabBarButtonRepeatClickNotification object:nil];
    
   //    NSString*token=[[NSUserDefaults standardUserDefaults]objectForKey:ACCESS_TOKEN];
//    [[NSUserDefaults standardUserDefaults]synchronize];
//    [self.socket sendString:[NSString stringWithFormat:@"SystemCode=GuangleHighway&Token=%@",token] error:nil];
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(getCarManagerWebSocketDataNotifacation:) name:@"carmanager" object:nil];
    
}
//点击tabbar图标
- (void)tabBarButtonRepeatClick {
    [self defaultAnnimation];
        [self selectRefresh];
    
    NSLog(@"点击两次");
}
//接收webSocket推送通知
-(void)getCarManagerWebSocketDataNotifacation:(NSNotification*)noti
{
    NSDictionary*dic=[noti userInfo];
    NSString*string=[dic objectForKey:@"车辆管理"];
    
    NSString *str=@"3:";//动态数据
    NSString *str2=@"2:";//离开数据
    
    //离开
    if ([string containsString:str2]) {
        NSString *temp = [string stringByReplacingOccurrencesOfString:str2 withString:@""];
        NSMutableArray *arr=[temp mj_JSONObject];
//        DataCodeModel *ReceiveModel=[DataCodeModel mj_objectWithKeyValues:dic];
//        NSArray *arr=[ReceiveModel.DataValue mj_JSONObject];
        for (NSDictionary *dic in arr) {
            CarManagerModel *carModel=[CarManagerModel mj_objectWithKeyValues:dic];
            NSLog(@"%@",carModel.VehicleNo);
            for (int i=0; i<_dataArray.count; i++) {
                CarManagerModel *model=_dataArray[i];
                if ([model.VehicleNo isEqualToString:carModel.VehicleNo]) {
                    [_dataArray removeObject:model];
                    i--;
                }
            }
        }
    }
    //动态数据
    if ([string containsString:str]) {
        [_mapView removeAnnotations:_pointArray];
        NSString *temp = [string stringByReplacingOccurrencesOfString:str withString:@""];
        NSMutableArray *arr=[temp mj_JSONObject];
//        DataCodeModel *ReciveModel=[DataCodeModel mj_objectWithKeyValues:dic];
        
//        NSArray *arr=[ReciveModel.DataValue mj_JSONObject];
        for (NSDictionary *dic in arr) {
            CarManagerModel *carModel=[CarManagerModel mj_objectWithKeyValues:dic];
            NSLog(@"%@",carModel.VehicleNo);
            NSInteger dynamicCount=_dataArray.count;
            BOOL YON=false;
            for (int i=0; i<dynamicCount; i++) {
                CarManagerModel *model=_dataArray[i];
                if ([model.VehicleNo isEqualToString:carModel.VehicleNo]) {
                    [_dataArray removeObject:model];
                    [_dataArray addObject:carModel];
                    dynamicCount--;
                    i--;
                    YON=true;
                }
            }
            if(!YON)
            {
                [_dataArray addObject:carModel];
            }
        }
    }
    [self loadAnimation:_dataArray];
    [_luzhengArray removeAllObjects];
    [_jiuyuanArray removeAllObjects];
    [_yanghuArray removeAllObjects];
    [_xiaofangArray removeAllObjects];
    [_xingzhengArray removeAllObjects];
    for (CarManagerModel *carModele  in _dataArray) {
        switch (carModele.VehicleType) {
            case 1:
                [_luzhengArray addObject:carModele];
                break;
            case 2:
                [_jiuyuanArray addObject:carModele];
                break;
            case 3:
                [_yanghuArray addObject:carModele];
                break;
            case 4:
                [_xiaofangArray addObject:carModele];
                break;
            default:
                [_xingzhengArray addObject:carModele];
                break;
        }
    }

}
// 告警
- (IBAction)GaojinBtn:(UIButton *)sender {
    GaoJinViewController *GaojinVC=[[GaoJinViewController alloc] init];
    GaojinVC.type=2;
    [self.navigationController pushViewController:GaojinVC animated:YES];
}


-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = YES;
    self.tabBarController.tabBar.hidden = NO;
    
    if (!self.socket) {
        AppDelegate*delegate=(AppDelegate*)[UIApplication sharedApplication].delegate;
        
        self.socket=delegate.socket;

    }
     [self.socket sendString:[NSString stringWithFormat:@"InternalVehicle=True"] error:nil];
//    self.socket = [[JFRWebSocket alloc] initWithURL:[NSURL URLWithString:@"ws://120.76.152.148:6070"] protocols:@[@"chat",@"superchat"]];
//    
//    self.socket.delegate = self;
//    [self.socket connect];
}

-(void)addCarView {
    _carView=[[CarManagerView alloc] initWithFrame:CGRectMake(0, [UIScreen mainScreen].bounds.size.height, self.view.frame.size.width, BottomSliderViewH)];
    [self.view addSubview:_carView];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(CarManagerDetail)];
    [_carView addGestureRecognizer:tap];
}

-(void)CarManagerDetail {
    InVehicleDetailViewController *vc = [[InVehicleDetailViewController alloc] init];
    vc.carModel        = _carView.model ;
    [self.navigationController pushViewController:vc animated:YES];
}

- (IBAction)Menu:(UIButton *)sender {
    _menu.selected = !_menu.selected;
    if (_menu.selected) {
        
        [UIView animateWithDuration:0.3 animations:^{
            _HengView.alpha=0;
            _shuView.alpha=0;
        }];
    }
    else {
        [UIView animateWithDuration:0.3 animations:^{
            _HengView.alpha = 1;
            _shuView.alpha  = 1;
        }];
    }
}
//养护
- (IBAction)yanghu:(UIButton *)sender {
    if (![[RightCodeTool sharedTool] rightIsEqualTO:@"P0302"]) {
        [SVProgressHUD showWithStatus:@"没有该权限"];
        return;
    }
//    [_socket disconnect];
    [self loadAnimation:_yanghuArray];
}
//拯救
- (IBAction)zhengjiu:(UIButton *)sender {
    if (![[RightCodeTool sharedTool] rightIsEqualTO:@"P0303"]) {
        [SVProgressHUD showWithStatus:@"没有该权限"];
        return;
    }
//    [_socket disconnect];
    [self loadAnimation:_jiuyuanArray];
}
//路政
- (IBAction)luzheng:(UIButton *)sender {
    if (![[RightCodeTool sharedTool] rightIsEqualTO:@"P0301"]) {
        [SVProgressHUD showWithStatus:@"没有该权限"];
        return;
    }
//    [_socket disconnect];
    [self loadAnimation:_luzhengArray];
}
//行政
- (IBAction)xingzheng:(UIButton *)sender {
    if (![[RightCodeTool sharedTool] rightIsEqualTO:@"P0304"]) {
        [SVProgressHUD showWithStatus:@"没有该权限"];
        return;
    }
//    [_socket disconnect];
    [self loadAnimation:_xingzhengArray];
}
//路况
- (IBAction)lukuang:(UIButton *)sender {
    _lukuangBtn.selected=!_lukuangBtn.selected;
    if (_lukuangBtn.selected) {
        [_lukuangBtn setBackgroundImage:[UIImage imageNamed:@"traffic_light_selected"] forState:UIControlStateNormal];
        _mapView.showTraffic=YES;
    }
    else {
        [_lukuangBtn setBackgroundImage:[UIImage imageNamed:@"traffic_light"] forState:UIControlStateNormal];
        _mapView.showTraffic=NO;
    }
}
//刷新
- (IBAction)shuaxin:(UIButton *)sender {
//    [_socket connect];
    [_dataArray removeAllObjects];
    [self Request];
}
//录入
- (IBAction)luru:(UIButton *)sender {
    if (![[RightCodeTool sharedTool] rightIsEqualTO:@"P0306"]) {
        [SVProgressHUD showErrorWithStatus:@"没有该权限"];
        return;
    }
//    [_socket disconnect];
    EnterMessageController *enterModer=[[EnterMessageController alloc] init];
    enterModer.CarIdArray=_CarIdArray;
    [self.navigationController pushViewController:enterModer animated:YES];
}
//查询
- (IBAction)chaxun:(UIButton *)sender {
//    [_socket disconnect];
    VehicleInquiryController *vc = [[VehicleInquiryController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}

//地图放大
- (IBAction)big:(id)sender {
    _la-=0.1;
    _lo-=0.1;
    MACoordinateSpan span = MACoordinateSpanMake(_la,_lo);
    CLLocationCoordinate2D centerCoordinate = CLLocationCoordinate2DMake(24.140485, 113.252132);
    MACoordinateRegion region = MACoordinateRegionMake(centerCoordinate, span);
    [_mapView setCenterCoordinate:centerCoordinate];
    _mapView.region = region;
}
//缩放地图
- (IBAction)small:(id)sender {
    _la+=0.3;
    _lo+=0.3;
    MACoordinateSpan span = MACoordinateSpanMake(_la, _lo);
    CLLocationCoordinate2D centerCoordinate = CLLocationCoordinate2DMake(24.140485, 113.252132);
    MACoordinateRegion region = MACoordinateRegionMake(centerCoordinate, span);
    [_mapView setCenterCoordinate:centerCoordinate];
    _mapView.region = region;
}
//加载地图视图
-(void)loadMapView {
    [AMapServices sharedServices].apiKey = GETGAODEPAIKEY;
    
    _mapView = [[MAMapView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height)];
    _mapView.delegate = self;
    _mapView.showsCompass = NO;
    _mapView.showsScale   = YES ;
    _mapView.scaleOrigin  = CGPointMake(10, CGRectGetHeight(self.view.bounds) - 70);
    [self.view addSubview:_mapView];
}

-(void)defaultAnnimation { // 2.968846--1.832185--8.631634--24.343247--113.323544
    MACoordinateSpan span = MACoordinateSpanMake(2.968846, 1.832185);
    CLLocationCoordinate2D centerCoordinate = CLLocationCoordinate2DMake(24.343247, 113.323544);
    MACoordinateRegion region = MACoordinateRegionMake(centerCoordinate, span);
    _mapView.region = region;
    [_mapView setCenterCoordinate:centerCoordinate animated:NO];
    _mapView.zoomLevel = 8.631634;
}

-(void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [self addCarView];
    [self.view addSubview:_menu];
    // **************************************  -权限-   **************************************
    if (![[RightCodeTool sharedTool] rightIsEqualTO:@"P0304"]) {
        _xingzhengBtn.hidden = YES;
    }
    if (![[RightCodeTool sharedTool] rightIsEqualTO:@"P0301"]) {
        _luzhengBtn.hidden = YES;
    }
    if (![[RightCodeTool sharedTool] rightIsEqualTO:@"P0303"]) {
        _jiuyuanBtn.hidden = YES;
    }
    if (![[RightCodeTool sharedTool] rightIsEqualTO:@"P0302"]) {
        _yanghuBtn.hidden = YES;
    }
    
    [self.view addSubview:_HengView];
    [self.view addSubview:_shuView];
    [self.view addSubview:_scaleView];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
//    [self.socket writeString:@"InternalVehicle=false"];
    [self.socket sendString:[NSString stringWithFormat:@"InternalVehicle=False"] error:nil];
    [UIView animateWithDuration:0.35 animations:^{
        _carView.transform    = CGAffineTransformIdentity;
        _scaleView.transform  = CGAffineTransformIdentity;
    }];
    [SVProgressHUD dismiss];
}

-(void)loadAnimation:(NSMutableArray *)mutableArray {
    [_mapView removeAnnotations:_pointArray];
    [_pointArray removeAllObjects];
    if (mutableArray.count>0) {
        for (int i=0;i<mutableArray.count;i++) {
            ROPointAnnotation *pointAnnotation        = [[ROPointAnnotation alloc] init];
            CarManagerModel *model                    = mutableArray[i];
            pointAnnotation.coordinate                = CLLocationCoordinate2DMake(model.Latitude , model.Longitude);;
            pointAnnotation.title                     = [NSString stringWithFormat:@"%@",model.VehicleNo];
            if (model.Attribution) {
                pointAnnotation.subtitle                  = [NSString stringWithFormat:@"%@",model.Attribution];
            }
            pointAnnotation.carManModel               = model;
            [_pointArray addObject:pointAnnotation];
        }
        [_mapView addAnnotations:_pointArray];
    }
    else {
//        [SVProgressHUD showSuccessWithStatus:@"无车辆数据!"];
//        return;
    }
}

- (MAAnnotationView *)mapView:(MAMapView *)mapView viewForAnnotation:(id <MAAnnotation>)annotation {
    
    if ([annotation isKindOfClass:[MAPointAnnotation class]]) {
        static NSString *pointReuseIndentifier = @"pointReuseIndentifier";
        CustomAnnotationView *annotationView = (CustomAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:pointReuseIndentifier];
        if (annotationView == nil) {
            annotationView = [[CustomAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:pointReuseIndentifier];
        }
        annotationView.canShowCallout = NO;       //设置气泡可以弹出，默认为NO
        ROPointAnnotation *anno       = (ROPointAnnotation *)annotation;
        annotationView.carManModel    = anno.carManModel;
        
        switch (anno.carManModel.VehicleType) {
            case 1:
                if([anno.carManModel.OD_Rate isEqualToString:@"0"]) {//路政
                    annotationView.image = [UIImage imageNamed:@"road_admin_stop"];
                } else {
                    annotationView.image = [UIImage imageNamed:@"road_admin_move"];
                }
                break;
                
            case 2:
                if([anno.carManModel.OD_Rate isEqualToString:@"0"]) { //拯救
                    annotationView.image = [UIImage imageNamed:@"save_stop"];
                } else {
                    annotationView.image = [UIImage imageNamed:@"save_move"] ;
                }
                break;
                
            case 3:
                if([anno.carManModel.OD_Rate isEqualToString:@"0"]) {//养护
                    annotationView.image = [UIImage imageNamed:@"conservation_stop"];
                }else {
                    annotationView.image = [UIImage imageNamed:@"conservation_move"] ;
                }
                break;
                
            case 4:
                break;
                
            default:
                if([anno.carManModel.OD_Rate isEqualToString:@"0"]) {//行政
                    annotationView.image = [UIImage imageNamed:@"administrative_stop"];
                } else {
                    annotationView.image = [UIImage imageNamed:@"administrative_move"];
                }
                break;
        }
        annotationView.centerOffset = CGPointMake(0, -annotationView.image.size.height / 2);
        return annotationView;
    }
    return nil;
}
- (void) clearArray {
    [_dataArray removeAllObjects];
    [_luzhengArray removeAllObjects];
    [_jiuyuanArray removeAllObjects];
    [_yanghuArray removeAllObjects];
    [_xiaofangArray removeAllObjects];
    [_xingzhengArray removeAllObjects];
    [_CarIdArray removeAllObjects];
}
//刷新数据
-(void)selectRefresh {
    [self clearArray];
    [SVProgressHUD showWithStatus:@"正在加载中..."];
    RequestHelper *requestHelper=[[RequestHelper alloc] init];
    RequestGinsengModel *getCurrentEventModel=[[RequestGinsengModel alloc] init];
    getCurrentEventModel.URL=GetVehicleDataURL;
    getCurrentEventModel.DataValue = @"";
    getCurrentEventModel.UpdatedTime = [requestHelper getCurrentTime];
    getCurrentEventModel.SystemCode = @"GuangleHighway";
    getCurrentEventModel.MethodName = @"GetAllInternalVehicleDynamicData";
    requestHelper.block  = ^(RequestOutginseng *requestOutginseng,id dataValueModel){
        
        if ([requestOutginseng.Code isEqualToString:@"001"]) {
           // [SVProgressHUD showSuccessWithStatus:@"加载完毕"];
            _dataArray = [CarManagerModel mj_objectArrayWithKeyValuesArray:requestOutginseng.DataValue];
            [self loadAnimation:_dataArray];
            if (_dataArray) {
                for (CarManagerModel *carModele  in _dataArray) {
                    [_CarIdArray addObject:carModele.VehicleNo];
                    switch (carModele.VehicleType) {
                        case 1:
                            [_luzhengArray addObject:carModele];
                            break;
                        case 2:
                            [_jiuyuanArray addObject:carModele];
                            break;
                        case 3:
                            [_yanghuArray addObject:carModele];
                            break;
                        case 4:
                            [_xiaofangArray addObject:carModele];
                            break;
                        default:
                            [_xingzhengArray addObject:carModele];
                            break;
                    }
                    [SVProgressHUD dismiss];
                }
                NSLog(@"%@",_CarIdArray);
            }else {
                [SVProgressHUD showErrorWithStatus:@"没有内部车辆的数据"];
            }
            [SVProgressHUD dismiss];
        }
        
    };
    [requestHelper RequestGinsengModel:getCurrentEventModel andPushController:self];
}
//刷新数据
- (void) Request{
     [SVProgressHUD showWithStatus:@"正在加载中..."];
    [self clearArray];
    RequestHelper *requestHelper=[[RequestHelper alloc] init];
    RequestGinsengModel *getCurrentEventModel=[[RequestGinsengModel alloc] init];
    getCurrentEventModel.URL=GetVehicleDataURL;
    getCurrentEventModel.DataValue = @"";
    getCurrentEventModel.UpdatedTime = [requestHelper getCurrentTime];
    getCurrentEventModel.SystemCode = @"GuangleHighway";
    getCurrentEventModel.MethodName = @"GetAllInternalVehicleDynamicData";
    requestHelper.block  = ^(RequestOutginseng *requestOutginseng,id dataValueModel){
        if ([requestOutginseng.Code isEqualToString:@"001"]) {
//            [SVProgressHUD showSuccessWithStatus:@"加载完毕"];
            _dataArray = [CarManagerModel mj_objectArrayWithKeyValuesArray:requestOutginseng.DataValue];
            [self loadAnimation:_dataArray];
            if (_dataArray) {
                for (CarManagerModel *carModele  in _dataArray) {
                    [_CarIdArray addObject:carModele.VehicleNo];
                    switch (carModele.VehicleType) {
                        case 1:
                            [_luzhengArray addObject:carModele];
                            break;
                        case 2:
                            [_jiuyuanArray addObject:carModele];
                            break;
                        case 3:
                            [_yanghuArray addObject:carModele];
                            break;
                        case 4:
                            [_xiaofangArray addObject:carModele];
                            break;
                        default:
                            [_xingzhengArray addObject:carModele];
                            break;
                    }
                }
                NSLog(@"%@",_CarIdArray);
                [SVProgressHUD dismiss];
            }else {
                [SVProgressHUD showErrorWithStatus:@"没有内部车辆的数据"];
            }
        }
    };
    [requestHelper RequestGinsengModel:getCurrentEventModel andPushController:self];
}



-(void)mapView:(MAMapView *)mapView didSelectAnnotationView:(MAAnnotationView *)view {
    CustomAnnotationView *customView     = (CustomAnnotationView *)view;
    [UIView animateWithDuration:0.35 animations:^{
        _carView.model       = customView.carManModel;
        [_carView setCarNum:customView.carManModel.VehicleNo carType:customView.carManModel.VehicleType vehicleSpeed:customView.carManModel.OD_Rate carDirection:customView.carManModel.Direction];
        _carView.transform   = CGAffineTransformMakeTranslation(0, BottomSliderDistance);
        _scaleView.transform = CGAffineTransformMakeTranslation(0, -BottomSliderViewH);
    }];
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [UIView animateWithDuration:0.35 animations:^{
        _carView.transform    = CGAffineTransformIdentity;
        _scaleView.transform  = CGAffineTransformIdentity;
        
    }];
    
}
- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    [SVProgressHUD dismiss];
}


@end
